/*****************************************************************************************
This file is a part of Arise library.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

Arise Engine		Timer.cpp

					E-mail:		arise_engine@mail.ru

					Origin by:	DK Engine 0.019,
								dev (avon.dn.ua@gmail.com), Agressor (agress0r@mail.ru)

created:			12.12.2003
last changes:		28.02.2008
*****************************************************************************************/
#include "stdafx.h"


Timer::Timer()
{
	m_time			= 0.0f;
	m_delta_time	= 0.0f;
	m_fps			= 0;
	m_fps_counter	= 0;

	m_last_time = m_last_time_fps = timeGetTime();
}


void Timer::Update()
{
	m_delta_time = (timeGetTime() - m_last_time) / 1000.0f;
	m_time += m_delta_time;

	m_last_time = timeGetTime();
	if(m_last_time - m_last_time_fps < 1000)
	{
		m_fps_counter++;
	}
	else
	{
		m_fps			= m_fps_counter;
		m_fps_counter	= 0;
		m_last_time_fps	= m_last_time;
	}
}